/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Helper;

/**
 *
 * @author Caliste
 */
public class TimerHelper 
{
    /**
     * Cette methode convert le temps en milliseconde
     * en format de temps "hh : mm : ss".
     * @param milliseconds
     * @return 
     */
    public static String GetTimeFormat(long milliseconds)
    {
        int seconds = (int) (milliseconds / 1000) % 60 ;
        int minutes = (int) ((milliseconds / (1000*60)) % 60);
        int hours   = (int) ((milliseconds / (1000*60*60)) % 24);
        
        StringBuilder sb = new StringBuilder();
        if(hours > 0)
        {
            sb.append(hours).append(" : ");
        }
        
        if(minutes > 0)
        {          
            if(minutes > 9)
            {
                sb.append(minutes).append(" : ");
            }
            else
            {
                sb.append("0").append(minutes).append(" : ");
            }
        }
        
        if(seconds > 9)
        {
            sb.append(seconds);
        }
        else
        {
            sb.append("0").append(seconds);
        }
        
        return sb.toString();
    }
}
